<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ page isELIgnored="false" %>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">

<html>
<head>
   <link href="<s:url value="/resources"/>/css/style_new.css" rel="stylesheet" type="text/css" />
    <link href="<s:url value="/resources"/>/css/main_new.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/cupertino/jquery-ui.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.multiselect.css" />
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script>  
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/grid.locale-cn.js"></script> 
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
<style>
html,body {
	margin: 0;
	padding: 0;
	font-size: 85%;
}
</style>
<script >
    
     var qieye = 0;
$(function(){
	$("#yind").button();
    $("#chax").button(); 
    // $("#excel").button();
	//$("#excel").hide();
    $("#reset").button();
        
    loadTab(0);
    //queryNum();
    
    //日期控件处理
    $( "#datepicker" ).datepicker($.datepicker.regional[ "zh-CN" ]);
    $( "#datepicker1" ).datepicker($.datepicker.regional[ "zh-CN" ]);
 
	function loadTab(i){	
		if(i==0){
			loadBdxx(i);
		}else{
			loadYdxx(i);
		}
  		$("#myTab"+i).jqGrid('setGridHeight','300px');
  	}  
	

    $( "#tabs" ).tabs({
		    select: function(event, ui) {
		    var i =ui.index;	    
		    if(i==''){
		    i="0";
		    }
		    qieye = i;
		    loadTab(i);
		    //$("#myTab"+qieye).jqGrid('setGridParam',{url:'findVerifyHtxxList.action?index='+qieye,mtype:'post',page:1}).trigger("reloadGrid");
		   // alert("aa");
		    //jQuery("#myTab1").jqGrid('hideCol',["Verify"]);
		        
            //return false;
  		  }
		
	});
	
	
 });
  

	

  
  
  function loadBdxx(i){
      $("#myTab"+i).jqGrid({      
    url:'findDianzdd',  
    datatype: 'json',
    mtype: 'post',         
   	colNames:['操作','合同编号','铁路计划号','年份','月份','发站','到站','发货单位名称','收货单位名称','批准数量','批准车数','订单状态','sysid','asysid'],
   	colModel:[ 
   	    {name:'Verify',index:'id',width:60,align:"center",sortable:false},
   	    {name:'hetddh',index:'hetddh', width:120},
   	    {name:'dingdbh',index:'dingdbh', width:120},
   	    {name:'nianf',index:'nianf', width:60},
   		{name:'yuef',index:'yuef', width:60 },
   		{name:'fazhmch',index:'fazhmch', width:60},
   		{name:'daozh',index:'daozh', width:60 },
   		{name:'fahdwmch',index:'fahdwmch', width:200 },
   		{name:'shouhdwmch',index:'shouhdwmch', width:200 },
   		{name:'pizhshl',index:'pizhshl', width:60 },
   		{name:'pizhchsh',index:'pizhchsh', width:60 },
   		{name:'zt',index:'zt', width:90},
   		{name:'sysid',index:'sysid', width:65,   hidden:true},
   		{name:'asysid',index:'sysid', width:65,   hidden:true}		
   	],
   
    jsonReader: {
           repeatitems : false, 
           id: 'asysid'
         },    	
   	rowNum:10,
    width: 1200,
   	rowList:[10,20,30],     	
   	pager: '#pager'+i,   	
   	rownumbers: true,   	 
    viewrecords: true,
    //multiselect: sign,
    sortorder: 'desc',  
    altRows:true,  
	//caption: "报单列表",
	gridComplete:function()
	{ //在此事件中循环为每一行添加修改和删除链接 
		var ids=jQuery("#myTab"+i).jqGrid('getDataIDs'); 	
		for(var j=0; j<ids.length; j++)
		{ 
			var id=ids[j];	
			
			verify ="<a href='#' style='color:#f60' onclick='Verify1("+ id +")'>打印</a>";
 
			jQuery("#myTab"+i).jqGrid('setRowData',ids[j], { Verify: verify}); 
		} 
	} 	
  });
  }
 

  function loadYdxx(i){
      $("#myTab"+i).jqGrid({      
    url:'findydbdlist?mmlx=6&index='+i,  
    datatype: 'json',
    mtype: 'post',         
   	colNames:['操作','合同编号','铁路计划号','发站','到站','收货单位名称','批准数量','批准车数','订单状态','sysid','asysid'],
   	colModel:[ 
   	    {name:'Verify',index:'id',width:60,align:"center",sortable:false},
   	    {name:'yingdbh',index:'yingdbh', width:120},
   	    {name:'baodrdwmc',index:'baodrdwmc', width:200},
   		{name:'sfhdwmc',index:'sfhdwmc', width:200},
   		{name:'yingdsl',index:'yingdsl', width:60 },
   		{name:'yingdsl',index:'yingdsl', width:60 },
   		{name:'yingdsl',index:'yingdsl', width:60 },
   		{name:'yingdsl',index:'yingdsl', width:60 },
   		{name:'yingdsj',index:'yingdsj', width:65},
   		{name:'sysid',index:'sysid', width:65},
   		{name:'asysid',index:'asysid', width:65}
   	],
   
    jsonReader: {
           repeatitems : false, 
           id: 'sysid'
         },    	
   	rowNum:10,
   	rowList:[10,20,30],     	
   	pager: '#pager'+i,   	
   	rownumbers: true,   	 
    viewrecords: true,
    //multiselect: sign,
    sortorder: 'desc',  
    altRows:true,  
	//caption: "报单列表",
	gridComplete:function()
	{ //在此事件中循环为每一行添加修改和删除链接 
		var ids=jQuery("#myTab"+i).jqGrid('getDataIDs');
	
		for(var j=0; j<ids.length; j++)
		{ 
			var id=ids[j];	
			 
			verify ="<a href='#' style='color:#f60' onclick='select("+ id +")'>编辑|查看</a>";							
			jQuery("#myTab"+i).jqGrid('setRowData',ids[j], { Verify: verify }); 
		} 
	} 	
  });
  }

  function openwindow(url){
    var sheight = screen.height-70;
    var swidth = screen.width-10;
    var winoption ="dialogHeight:"+sheight+"px;dialogWidth:"+ swidth +"px;status:yes;scroll:yes;resizable:yes;center:yes";
    var result=window.showModalDialog(url,window,winoption);
    if(result ==1){
     reloadYdxx(); 
     }
    return result;  
	}
  
	function reloadYdxx(){
	   window.location.href="<%=request.getContextPath()%>/gpjy/buyydlist";
	}
  
	//单击修改链接的操作 
   function Verify1(id) { 
	   if(id.id!=undefined){
		   var rowData = jQuery("#myTab"+qieye).jqGrid("getRowData", id.id);  
		   window.open('<%=path %>/jhtbedit/getDianzdd?sysid='+rowData.sysid+'&zt=2',"_blank");
	    }
    }
  // 查询
	function search(){   
	  var formdata = $("#form1").serialize();  
	  $("#myTab"+qieye).jqGrid('setGridParam',{url:'findDianzddSearch?'+formdata,mtype:'post',page:1}).trigger("reloadGrid"); 
	  //queryNum();
	}

	function queryNum(){   
		  var formdata = $("#form1").serialize(); 
		  $.post("<%=path%>/htgl/findVerifyHtxxListNum.action",formdata,function(data,textStatus)
		  {
		  var json = eval('(' + data + ')');
		  var re=/(\d{1,3})(?=(\d{3})+(?:$|\.))/g;
		if (json[0].shul !="")
		{
		  // alert("价格范围："+json[0].jiag + "  总数量："+json[0].shul+"  总金额："+json[0].jine);
		   $("#queryNum").html("价格范围："+json[0].jiag + "元/吨  总数量："+json[0].shul.toString().replace(re,"$1,")+"吨  总金额："+json[0].jine.toString().replace(re,"$1,")+"元");
		 }
		  });
		  
		}

	 function txt_onblur(i) {
            if (!event.srcElement.value) {
                event.srcElement.value = '0';
            }
            if (isNaN(temp)) {
                $("#"+i).val(0);                
            } 
        }
        
    //重置
	function resetSearch()
    {
		$('#list_search  input[type=text]').val('');
		$('#list_search select').val('-1');
	}
  
   ///excel
	function exportexcel(){ 
	  var formdata = $("#form1").serialize(); 
	  window.location.href("<s:url value="/jhtbedit"/>/excelForDzdd?"+formdata);
	
	}
	</script>

</head>

<body>
	<div class="container">
    <div class="containerbox">
      <div class="btn-bar"> 
        <a id="excel" href="#" class="btn" onclick="exportexcel();"><img src="<s:url value="/resources"/>/img/25.gif" /> <span>导出excel</span></a>
      </div>
		<div class="search mt10" id="list_search">
		<form id="form1" method="post">
			<table class="search-table" width="90%"  cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td>合同编号:</td>
					<td><input type="text" class="form-textbox" style="width: 200px;" name="aa" />
					</td>
 
					<td>品种 :</td>
					<td>
						<div class="select">
							<select name="cc" class="form-textbox" style="width: 200px;">
								<option value="-1" selected>==请选择==</option>
								<c:forEach var="pz" items="${pinz}">
									<option value="${pz.diccode}">${pz.dicname}</option>
								</c:forEach>
							</select>

						</div>
					</td>
					<!-- <td>出卖人:</td>
					<td><input type="text" class="form-textbox" style="width: 200px;" name="ff" />
					</td>	 -->				
					<!-- <td>买受人:</td>
					<td><input type="text" class="form-textbox" style="width: 200px;" name="gg" />
					</td>	 -->			
				<td>提报时间:</td>
					<td><input id="datepicker" type="text" class="form-textbox" style="width: 93px;"
						name="dd" /> -- <input id="datepicker1" type="text"
						class="form-textbox" style="width: 93px;" name="ee" />
					</td>
					</tr>
				<tr>
				<td>批准吨数:</td>
					<td><input id="shul" type="text" class="form-textbox" style="width: 93px;"
						name="jj"  style="width:80px" /> -- <input id="shul1" type="text"
						class="form-textbox" style="width: 93px;" name="kk"
						style="width:80px" />
					</td>
					<td>局、发站:</td>
					<td><input type="text" class="form-textbox" style="width: 200px;" name="hh" />
					</td>
					<td>局、到站:</td>
					<td><input type="text" class="form-textbox" style="width: 200px;" name="ii" />
					</td>
					</tr>
				<tr>
					<td>发货单位:</td>
					<td><input type="text" class="form-textbox" style="width: 200px;" name="oo" />
					</td>
					<td>收货单位:</td>
					<td><input type="text" class="form-textbox" style="width: 200px;" name="pp" />
					</td>
					<td>年份:</td>
					<td><div class="pr10 search-table-70"><div>
					      <select name="ll" class="form-textbox" style="width: 200px;">
					          <option value="2014">2014</option>
					          <option value="2015" selected>2015</option>
					          <option value="2016">2016</option>
					      </select>
					      </div></div></td>
					      </tr>
				<tr>
					<td>月份：</td>
					<td><div class="pr10 search-table-70"><div>
					      <select name="nn" class="form-textbox" style="width: 200px;">
					          <option value="-1" selected>==请选择==</option>
					          <option value="1">1月</option>
					          <option value="2">2月</option>
					          <option value="3">3月</option>
					          <option value="4">4月</option>
					          <option value="5">5月</option>
					          <option value="6">6月</option>
					          <option value="7">7月</option>
					          <option value="8">8月</option>
					          <option value="9">9月</option>
					          <option value="10">10月</option>
					          <option value="11">11月</option>
					          <option value="10">12月</option>
					      </select>
					      </div></div></td>
				</tr>

				<tr>
    <td align="left" valign="middle" colspan="6">
<table border="0" cellspacing="0" cellpadding="0" >
  <tr>
    <td align="right" class="pr10 search-table-70">&nbsp;</td>
    <td align="left"><input name="" type="button" class="form-button-query form-button" value="查询" onclick="search();"/>
    <input name="" type="button" class="form-button-reset form-button" value="重置"  onclick="resetSearch();"/></td>
  </tr>
</table></td>
  </tr>
			</table>
		</form>
        </div>
		<div id="tabs">
			<ul>
				<li><a href="#tabs-0">电子订单</a></li>
				<li> </li>
				<li id="queryNum"  style="float:right; vertical-align: bottom; line-height:20px; top: 3px;"></li>
			</ul>
			<div id="tabs-0">
				<table id="myTab0" class="scroll" cellpadding="0" cellspacing="0"  ></table>
				<div id="pager0" class="scroll"></div>
				<div id="message0" class="scroll"></div>
			</div>
			<div id="tabs-1">
				<table id="myTab1" class="scroll" cellpadding="0" cellspacing="0"></table>
				<div id="pager1" class="scroll"></div>
				<div id="message1" class="scroll"></div>
			</div>

		</div>

		<div id="dialog-confirm" title="是否确认？"></div>
		</div>
		</div>
</body>
</html>
